package view_manage

import (
	"time"
	"vrcm/src/vrcm/app/admin/models/view"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type ViewFitGetPageReq struct {
	dto.Pagination `search:"-"`
	ViewFitOrder
}

type ViewFitOrder struct {
	Id           string `form:"idOrder"  search:"type:order;column:id;table:view_fit"`
	BindId       string `form:"bindIdOrder"  search:"type:order;column:bind_id;table:view_fit"`
	Name         string `form:"nameOrder"  search:"type:order;column:name;table:view_fit"`
	Introduction string `form:"introductionOrder"  search:"type:order;column:introduction;table:view_fit"`
	TechSupport  string `form:"techSupportOrder"  search:"type:order;column:tech_support;table:view_fit"`
	BackUrl      string `form:"backUrlOrder"  search:"type:order;column:back_url;table:view_fit"`
	PlayLogo     string `form:"playLogoOrder"  search:"type:order;column:play_logo;table:view_fit"`
	Logo         string `form:"logoOrder"  search:"type:order;column:logo;table:view_fit"`
	CreateTime   string `form:"createTimeOrder"  search:"type:order;column:create_time;table:view_fit"`
	IsDelete     string `form:"isDeleteOrder"  search:"type:order;column:is_delete;table:view_fit"`
}

func (m *ViewFitGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type ViewFitInsertReq struct {
	Id           int    `json:"-" comment:""` //
	BindId       string `json:"bind_id" comment:"" validate:"required,max=50"`
	Name         string `json:"name" comment:"名称" validate:"max=255"`
	Introduction string `json:"introduction" comment:"简介" validate:"max=500"`
	TechSupport  string `json:"tech_support" comment:"技术支持" validate:"max=255"`
	BackUrl      string `json:"back_url" comment:"背景图片" validate:"max=255"`
	PlayLogo     string `json:"play_logo" comment:"播放页logo" validate:"max=255"`
	Logo         string `json:"logo" comment:"头像" validate:"max=255"`
	common.ControlBy
}

func (s *ViewFitInsertReq) Generate(model *view.ViewFit) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.BindId = s.BindId
	model.Name = s.Name
	model.Introduction = s.Introduction
	model.TechSupport = s.TechSupport
	model.BackUrl = s.BackUrl
	model.PlayLogo = s.PlayLogo
	model.Logo = s.Logo
	model.IsDelete = "2"
	model.CreateBy = s.CreateBy
	model.CreateTime = time.Now().Unix()
	model.UpdateTime = time.Now().Unix()
}

func (s *ViewFitInsertReq) GetId() interface{} {
	return s.Id
}

type ViewFitUpdateReq struct {
	Id           int    `uri:"id" comment:""` //
	BindId       string `json:"bind_id" comment:"" validate:"required,max=50"`
	Name         string `json:"name" comment:"名称" validate:"max=255"`
	Introduction string `json:"introduction" comment:"简介"`
	TechSupport  string `json:"tech_support" comment:"技术支持" validate:"max=255"`
	BackUrl      string `json:"back_url" comment:"背景图片" validate:"max=255"`
	PlayLogo     string `json:"play_logo" comment:"播放页logo" validate:"max=255"`
	Logo         string `json:"logo" comment:"头像" validate:"max=255"`
	FitType      int    `json:"fit_type" comment:"装修类型 1国际直播 2全球直播" validate:"gt=0"`
	IsViewTime   int    `json:"is_view_time" comment:"显示观看次数 1是 2 否" validate:"gt=0"`
	common.ControlBy
}

func (s *ViewFitUpdateReq) Generate(model *view.ViewFit) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
		model.CreateBy = s.CreateBy
		model.CreateTime = time.Now().Unix()
		model.UpdateTime = time.Now().Unix()
	} else {
		model.UpdateBy = s.UpdateBy
		model.UpdateTime = time.Now().Unix()
	}
	model.BindId = s.BindId
	model.Name = s.Name
	model.Introduction = s.Introduction
	model.TechSupport = s.TechSupport
	model.BackUrl = s.BackUrl
	model.PlayLogo = s.PlayLogo
	model.Logo = s.Logo
	model.IsDelete = "2"
	model.FitType = s.FitType
	model.ViewPooleType = s.IsViewTime
}

func (s *ViewFitUpdateReq) GetId() interface{} {
	return s.Id
}

// ViewFitGetReq 功能获取请求参数
type ViewFitGetReq struct {
	Id     int    `uri:"id"`
	BindId string `json:"bind_id" comment:"" validate:"required"` //
}

func (s *ViewFitGetReq) GetId() interface{} {
	return s.Id
}

func (s *ViewFitGetReq) GetBindId() interface{} {
	return s.BindId
}

// ViewFitDeleteReq 功能删除请求参数
type ViewFitDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *ViewFitDeleteReq) GetId() interface{} {
	return s.Ids
}

type ViewReq struct {
	BindId string `json:"bind_id" comment:"" validate:"require"`
}

type ViewRes struct {
	Fit   *view.ViewFit   `json:"fit" comment:""`
	Limit *view.ViewLimit `json:"limit" comment:""`
}
